package com.chushouya.controller.order.clerk;

import com.chushouya.common.annotations.AuthValidate;
import com.chushouya.common.constant.ServiceType;
import com.chushouya.common.support.Contexts;
import com.general.framework.core.schema.Response;
import com.chushouya.order.dto.api.stat.ClerkOrderDayStatQuery;
import com.chushouya.order.dto.api.stat.ClerkOrderMonthDTO;
import com.chushouya.order.service.common.ClerkOrderDayStatTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Api(tags = ServiceType.CLERK + "业务员统计列表接口")
@RestController
@RequestMapping(ServiceType.CLERK + "/stat")
public class ClerkOrderStatApiController {

    @Resource
    private ClerkOrderDayStatTaskService clerkOrderDayStatTaskService;

    /**
     * 业务员统计列表
     */
    @GetMapping("/page")
    @AuthValidate
    @ApiOperation("业务员统计列表")
    public Response<List<ClerkOrderMonthDTO>> page(ClerkOrderDayStatQuery query) {
        query.setClerkId(Contexts.getUserContext().getClerkId());
        return Response.success(clerkOrderDayStatTaskService.statClerkOrderDayByMonth(query));
    }

}
